home *** CD-ROM | disk | FTP | other *** search
- ;void display_mem(segment,offset,num_chars,col,row,color);
- ; unsigned short segment,offset,num_chars;
- ; unsigned char col,row,color;
-
- EXTRN _memory_model:byte
- EXTRN _video_buffer:word
- EXTRN _snow_protect:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _display_mem
- _display_mem proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: mov cl,_snow_protect ;get _snow_protect
- push ds ;save Turbo's DS
- mov ax,_video_buffer ;fetch Videobuffer
- mov es,ax ;ES pts to buffer
- sub bx,bx ;
- mov bl,[bp+12] ;Row
- dec bx ;count from zero
- mov [bp+12],cl ;save _snow_protect
- sub cx,cx ;
- mov cl,[bp+10] ;Col
- dec cx ;count from zero
- mov ax,160 ;bytes per row
- mul bl ;row offset
- shl cx,1 ;dble cols for attributes
- add ax,cx ;offset to start position
- mov di,ax ;ES:DI pts to start
- mov ax,[bp+4] ;get segment
- mov ds,ax ;
- mov si,[bp+6] ;offset
- mov cx,[bp+8] ;number chars to display
- jcxz L5 ;quit if null
- cld ;forward direction
- mov ah,[bp+14] ;get screen attribute
- L1: lodsb ;get a char from memory
- cmp byte ptr[bp+12],0 ;protect against snow?
- je L4 ;jump if not
- push ax ;save char-attri
- mov dx,3dah ;status byte address
- L2: in al,dx ;get status byte
- test al,1 ;test bit
- jnz L2 ;loop till 0
- cli ;disable interrupts
- L3: in al,dx ;get status byte
- test al,1 ;test bit
- jz L3 ;loop till 1, then write
- pop ax ;restore char-attri
- L4: stosw ;write the char and color
- loop L1 ;loop till finished
- L5: sti ;reenable interrupts
- pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _display_mem endp
- _TEXT ENDS
- END